//
//  Marcro.h
//  通用框架宏
//
//  Created by EmberWei on 2017/07/03.
//  Copyright © 2017年 LimeKing. All rights reserved.
//

#ifndef Marcro_h
#define Marcro_h

// 企业更新地址
#define URL_ITMS @"itms-services://?action=download-manifest&url="
// 版本号
#define APP_VERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
// 系统版本号
#define IOS_VERSION [[UIDevice currentDevice] systemVersion]

#define iPhone4s (kScreenWidth == 320.f && kScreenHeight == 480.f)
#define iPhoneSE (kScreenWidth == 320.f && kScreenHeight == 568.f)
#define iPhone6s (kScreenWidth == 375.f && kScreenHeight == 667.f)
#define iPhone6P (kScreenWidth == 414.f && kScreenHeight == 736.f)
#define iPhoneX  (kScreenWidth == 375.f && kScreenHeight == 812.f)

// 强弱引用与Block回调
#define WEAK(type)    __weak typeof(type) weak##type = type;
#define STRONG(type)  __strong typeof(type) type = weak##type;
#define BLOCK_EXEC(block, ...) if (block) { block(__VA_ARGS__); };

// 颜色
#define HEXCOLOR(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

#define HEXCOLORA(rgbValue,A) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:A]

#define RANDOMCOLOR [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]

// 字体
#define FontL(s)             [UIFont systemFontOfSize:s weight:UIFontWeightLight]
#define FontR(s)             [UIFont systemFontOfSize:s weight:UIFontWeightRegular]
#define FontB(s)             [UIFont systemFontOfSize:s weight:UIFontWeightBold]
#define FontT(s)             [UIFont systemFontOfSize:s weight:UIFontWeightThin]
#define Font(s)              FontL(s)

// 字符串
#define FORMAT(f, ...)       [NSString stringWithFormat:f, ## __VA_ARGS__]
// 图片获取
#define IMAGE(A)             [UIImage imageNamed:A]
// 国际化
#define LS(s, ...)           NSLocalizedString(s, nil)
// 根据tag取出View
#define VIEW_TAG(v,tag)      [v viewWithTag:tag]

// 设备宽高
#define NAV_HEIGHT 64
#define TAB_HEIGHT 49

#define SCREEN_RECT ([UIScreen mainScreen].bounds)
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#define CONTENT_HEIGHT (SCREEN_HEIGHT - NAV_HEIGHT - TAB_HEIGHT)


//GCD - 一次性
#define GCD_ONCE(onceBlock) static dispatch_once_t onceToken; dispatch_once(&onceToken, onceBlock);
//GCD - 主线程
#define GCD_MAIN(mainQueueBlock) dispatch_async(dispatch_get_main_queue(), mainQueueBlock);
//GCD - 后台
#define GCD_BACK(globalQueueBlock) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), globalQueueBlocl);


//获取temp
#define PATH_TEMP NSTemporaryDirectory()
//获取沙盒 Document
#define PATH_DOC [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
//获取沙盒 Cache
#define PATH_CACHE [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]


// 一些常用的缩写
#define KEY_WINDOW          [UIApplication sharedApplication].keyWindow
#define APP_DELEGATE        [UIApplication sharedApplication].delegate
#define USER_DEFAULT        [NSUserDefaults standardUserDefaults]
#define NOTIF_CENTER        [NSNotificationCenter defaultCenter]


#endif /* Marcro_h */
